<template>
	<div class="category-content order-content">
		<div class="main-width">
			<div class="order-number" v-if="!statusShow">
				<span class="main-header-login">订单号：{{afterSalesDetail.afterSn}}</span>
			</div>
			<div class="order-status">
				<ul>
					<li class="order-detail-one order-status-one order-status-default yiwancheng">
						<div class="order-current-status"></div>
						<div class="order-status-text">提交申请</div>
					</li>
					<li class="order-detail-two order-status-two order-status-default yiwancheng" v-if="status1 == 1">
						<div class="order-current-status"></div>
						<div class="order-status-text">商家审核中</div>
					</li>
					<li class="order-detail-two order-status-two order-status-default yiwancheng" v-else-if="status1 == 2">
						<div class="order-current-status"></div>
						<div class="order-status-text">商家同意售后</div>
					</li>
					<li class="order-detail-two order-status-two order-status-default refuse" v-else-if="status1 == 3">
						<div class="order-current-status"></div>
						<div class="order-status-text">商家拒绝</div>
					</li>
					<li class="order-detail-three order-status-two order-status-default yiwancheng" v-if="status2 == 1">
						<div class="order-current-status"></div>
						<div class="order-status-text">商品回寄，商家处理中</div>
					</li>
					<li class="order-detail-three order-status-two order-status-default yiwancheng" v-else-if="status2 == 2">
						<div class="order-current-status"></div>
						<div class="order-status-text">退款成功</div>
					</li>
					<li class="order-detail-three order-status-two order-status-default" v-else>
						<div class="order-current-status"></div>
						<div class="order-status-text">等待中</div>
					</li>
					<li class="order-detail-four order-status-two order-status-default yiwancheng" v-if="status3 == 2">
						<div class="order-current-status"></div>
						<div class="order-status-text">售后完成</div>
					</li>
					<li class="order-detail-four order-status-two order-status-default" v-else-if="status3 == 1">
					</li>
					<li class="order-detail-four order-status-two order-status-default" v-else>
						<div class="order-current-status"></div>
						<div class="order-status-text">售后完成</div>
					</li>
				</ul>
			</div>
			<div class="afs-content-wrap mar-bot-20">
				<div class="afs-big-title">处理环节：</div>
				<div>
					<div class="afs-content" v-if="status3 == 2">
						<div class="afs-content-title">
							<div class="order-status-text big-font">售后完成</div>
							<!-- <div class="order-status-time">createDate</div>
							<div class="order-status-time">createTime</div> -->
						</div>
						<div class="afs-content-info">
							<div class="afs-content-info-wrap" :class="{'current': current==3}">
								<div class="order-status-text big-font">处理信息</div>
								<div class="order-status-time">售后完成</div>
								<div class="order-status-time">处理方：商家</div>
							</div>
						</div>
					</div>
					<div class="afs-content" v-if="status2 == 2">
						<div class="afs-content-title">
							<div class="order-status-text big-font">商家退款</div>
							<!-- <div class="order-status-time">createDate</div>
							<div class="order-status-time">createTime</div> -->
						</div>
						<div class="afs-content-info">
							<div class="afs-content-info-wrap" :class="{'current': current==3}">
								<div class="order-status-text big-font">处理信息</div>
								<div class="order-status-time">退款成功</div>
								<div class="order-status-time">处理方：商家</div>
							</div>
						</div>
					</div>
					<div class="afs-content" v-if="status2 == 1">
						<div class="afs-content-title">
							<div class="order-status-text big-font">商家退款</div>
							<!-- <div class="order-status-time">createDate</div>
							<div class="order-status-time">createTime</div> -->
						</div>
						<div class="afs-content-info">
							<div class="afs-content-info-wrap" :class="{'current': current==2}">
								<div class="order-status-text big-font">处理信息</div>
								<div class="order-status-time">退款成功</div>
								<div class="order-status-time">处理方：商家</div>
							</div>
						</div>
					</div>
					<div class="afs-content" v-if="status1 == 1">
						<div class="afs-content-title">
							<div class="order-status-text big-font">商家处理</div>
							<!-- <div class="order-status-time">createDate</div>
							<div class="order-status-time">createTime</div> -->
						</div>
						<div class="afs-content-info">
							<div class="afs-content-info-wrap" :class="{'current': current==2}">
								<div class="order-status-text big-font">处理信息</div>
								<div class="order-status-time">商家已收到申请，正在处理中</div>
								<div class="order-status-time">处理方：商家</div>
							</div>
						</div>
					</div>
					<div class="afs-content" v-if="status1 == 2">
						<div class="afs-content-title">
							<div class="order-status-text big-font">商家同意</div>
							<!-- <div class="order-status-time">createDate</div>
							<div class="order-status-time">createTime</div> -->
						</div>
						<div class="afs-content-info">
							<div class="afs-content-info-wrap" :class="{'current': current==2}">
								<div class="order-status-text big-font">处理信息</div>
								<div class="order-status-time">商家已经同意售后</div>
								<div class="order-status-time">处理方：商家</div>
								<div class="order-status-time" v-if="showLogistics">物流信息：</div>
								<div v-if="showLogistics">
									<div class="order-info-content">
										<div class="order-logistics-info">
											<div>
												物流公司：<span>{{logisticsDetail.company}}</span>
											</div>
											<div>
												收货方式：<span>普通快递</span>
											</div>
											<div>
												物流单号：<span>{{logisticsDetail.no}}</span>
											</div>
										</div>
										<div class="order-logistics-content afsOrder">
											<div class="order-logistics-item-wrap" v-for="(item, index) in logisticsDetail.list">
												<div class="order-logistics-item" :class="{'current': index==0}">
													<span>{{item.datetime}}</span>
													<span>{{item.remark}}</span>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="afs-content" v-if="status1 == 3">
						<div class="afs-content-title">
							<div class="order-status-text big-font">商家拒绝</div>
							<!-- <div class="order-status-time">createDate</div>
							<div class="order-status-time">createTime</div> -->
						</div>
						<div class="afs-content-info">
							<div class="afs-content-info-wrap" :class="{'current': current==2}">
								<div class="order-status-text big-font">处理信息</div>
								<div class="order-status-time">商家拒绝售后</div>
								<div class="order-status-time">处理方：商家</div>
							</div>
						</div>
					</div>
					<div class="afs-content">
						<div class="afs-content-title">
							<div class="order-status-text big-font">提交申请</div>
							<!-- <div class="order-status-time">createDate</div>
							<div class="order-status-time">createTime</div> -->
						</div>
						<div class="afs-content-info">
							<div class="afs-content-info-wrap">
								<div class="order-status-text big-font">处理信息</div>
								<div class="order-status-time">申请已提交，平台会在1-2个工作日内处理</div>
								<div class="order-status-time">处理方：系统</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div>
				<div v-if="statusShow">
					<div class="afs-block-title">售后信息</div>
					<div>
						<table class="shelves-table">
							<thead>
								<tr>
									<th>商品信息</th>
									<th>单价</th>
									<th>可退款金额</th>
									<th>运费</th>
								</tr>
							</thead>
							<tbody class="order-tbody">
								<tr class="order-table-item">
									<td class="order-table-image">
										<div class="order-table-image-wrap">
											<img :src="imgAddress + refundInfo.goodsImage" @error="error(1)"/>
										</div>
										<div>
											<div class="order-goods-name">{{refundInfo.goodsName}}</div>
											<div class="order-default-font order-guige">{{refundInfo.specName}}</div>
										</div>
									</td>
									<td class="order-default-font">¥{{refundInfo.goodsSalePrice/100}} X {{refundInfo.quantity}}(数量)</td>
									<td class="order-default-font">¥{{refundInfo.needRefund/100}}</td>
									<td class="order-default-font">¥{{refundInfo.needRefundFreight/100}}</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="afs-content-wrap mar-bot-20 no-border">
						<div class="afs-form-item">
							<label>售后类型：</label>
							<div>
								<span class="afs-form-check" :class="{'checked': isRefund==1}" @click="handleIsRefund">
									仅退款
									<a :class="{'checked': isRefund==1}"></a>
								</span>
								<span class="afs-form-check" :class="{'checked': isRefund==2}" @click="handleIsRefund">
									退货退款
									<a :class="{'checked': isRefund==2}"></a>
								</span>
							</div>
						</div>
						<div class="afs-form-item">
							<label>提交数量：</label>
							<div>
								<el-input-number v-model="num1" :min="1" :max="refundInfo.quantity"></el-input-number>
							</div>
						</div>
						<div class="afs-form-item">
							<label>退款说明：</label>
							<div>
								<el-select v-model="value" placeholder="请选择">
								    <el-option
								      v-for="item in options"
								      :key="item.reason"
								      :label="item.reason"
								      :value="item.reason">
								    </el-option>
								</el-select>
							</div>
						</div>
						<div class="afs-form-item">
							<label>问题描述：</label>
							<div class="textarea">
								<el-input type="textarea" v-model="desc" :rows="5"></el-input>
								<div class="afs-tip">不超过300字</div>
							</div>
							
						</div>
						<div class="afs-form-item">
							<label>图片信息：</label>
							<div class="textarea">
								<el-upload
								  action="https://jsonplaceholder.typicode.com/posts/"
								  list-type="picture-card"
								  ref="upload"
								  accept="image/*"
								  :auto-upload="false"
								  :file-list="fileList"
								  :on-preview="handlePictureCardPreview"
								  :on-change="handleChange"
								  :on-remove="handleRemove">
								  <i class="el-icon-plus" ></i>
								</el-upload>
								<el-dialog v-model="dialogVisible" size="tiny">
									<img width="100%" :src="dialogImageUrl" alt="">
								</el-dialog>
								<div class="afs-tip text-left">图片最多上传3张，每张图片大小不超过5M</div>
							</div>
							<el-button class="hot-search mar-left-10" size="small" type="primary" @click="saveAfs">确认提交</el-button>
						</div>
					</div>
				</div>
				<div v-else>
					<div class="afs-content-wrap padding-bot-20 mar-bot-20" v-if="afterSalesDetail.sendBack == 0&&afterSalesDetail.isRefund==2&&afterSalesDetail.status != 3&&afterSalesDetail.status != 4">
						<div>
							<div class="return-info">
								<span>收件人电话：{{address.mobile}}</span>
								<span class="main-header-login">收件人：{{address.linkMan}}</span>
							</div>
							<div class="return-info">
								收件人地址：{{address.province+address.city+address.area+address.address}}
							</div>
							<div class="afs-form-item">
								<label class="afs-inwrap">物流公司：</label>
								<div>
									<el-select v-model="company" @change="handleSelect" placeholder="请选择物流公司">
								    	<el-option
								      	v-for="item in logisticsData"
								      	:key="item.companyNo"
								      	:label="item.companyName"
								      	:value="item.companyNo">
								    	</el-option>
								  	</el-select>
								</div>
							</div>
							<div class="afs-form-item">
								<label class="afs-inwrap">物流单号：</label>
								<div>
									<el-input v-model="logisticsSn" placeholder="请输入物流单号"></el-input>
									<div class="tip">
										<i class="el-icon-information"></i>请将商品邮寄到上面地址，并填写物流公司，物流单号
									</div>
								</div>
							</div>
							<div class="afs-form-item">
								<div>
									<el-button type="primary" size="small" @click="saveLogistics">确认提交</el-button>
								</div>
							</div>
						</div>
					</div>
					<div class="mar-bot-20">
						<table class="shelves-table">
							<thead>
								<tr>
									<th>商品信息</th>
									<th>SKU</th>
									<th>最终结算价</th>
									<th>数量</th>
									<th>是否开票</th>
									<th>运费</th>
								</tr>
							</thead>
							<tbody class="order-tbody">
								<tr class="order-table-item">
									<td class="order-table-image">
										<div class="order-table-image-wrap">
											<img :src="imgAddress + afterSalesDetail.navigateImg1" @error="error(1)"/>
										</div>
										<div>
											<div class="order-goods-name">{{afterSalesDetail.goodsName}}</div>
										</div>
									</td>
									<td>
										<div class="order-default-font">{{afterSalesDetail.specName}}</div>
									</td>
									<td class="order-default-font">¥{{afterSalesDetail.refundFee/100}}</td>
									<td class="order-default-font">{{afterSalesDetail.refundAmount}}</td>
									<td class="order-default-font" v-if="afterSalesDetail.isBill == 0">未开发票</td>
									<td class="order-default-font" v-else>开发票</td>
									<td class="order-default-font">¥{{afterSalesDetail.refundPostage/100}}</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="afs-content-wrap padding-bot-20 mar-bot-20">
						<div class="afs-left">
							<div class="afs-infor-wrap">
								<div class="afs-block-title">售后信息</div>
								<div class="afs-infor">
									<div>
										退货店铺： {{address.linkMan}}
									</div>
									<div>
										退款理由： {{afterSalesDetail.applicationReason}}
									</div>
									<div>
										退款金额： ¥{{afterSalesDetail.refundFee/100}}
									</div>
									<div v-if="afterSalesDetail.isRefund == 1">
										售后类型： 退款
									</div>
									<div v-else>
										售后类型： 退货退款
									</div>
									<div class="afs-infor-item">
										<a>退款说明：</a><div>{{afterSalesDetail.userReason}}</div>
									</div>
								</div>
							</div>
						</div>
						<div class="afs-right">
							<div class="afs-image">
								<div class="afs-block-title mar-bot-20">售后图片</div>
								<div class="afs-image-list">
									<div>
										<img :src="imgAddress + afterSalesDetail.imgProof1" @error="error(2)"/>
									</div>
									<div>
										<img :src="imgAddress + afterSalesDetail.imgProof2" @error="error(2)"/>
									</div>
									<div>
										<img :src="imgAddress + afterSalesDetail.imgProof3" @error="error(2)"/>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="afs-content-wrap padding-bot-20 mar-bot-20" v-if="afterSalesDetail.sendBack == 0&&afterSalesDetail.isRefund==2&&afterSalesDetail.status != 1">
						<div>
							<div class="return-info">
								<span>收件人电话：{{address.mobile}}</span>
								<span class="main-header-login">收件人：{{address.linkMan}}</span>
							</div>
							<div class="return-info">
								收件人地址：{{address.province+address.city+address.area+address.address}}
							</div>
							<div class="afs-form-item">
								<label class="afs-inwrap">物流公司：</label>
								<div>
									{{afterSalesDetail.courierCompany}}
								</div>
							</div>
							<div class="afs-form-item">
								<label class="afs-inwrap">物流单号：</label>
								<div>
									{{afterSalesDetail.courierNumber}}
								</div>
							</div>
						</div>
					</div>
				<div class="afs-content-wrap padding-bot-20 mar-bot-20" v-if="showRefundList">
					<div>该笔订单下的售后单</div>
					<table class="shelves-table no-margin">
						<tbody class="order-tbody" v-for="item in refundList">
							<tr>
								<td colspan="7" class="self-tbody-space"></td>
							</tr>
							<tr>
								<td colspan="7" class="shelves-table-block-title no-select">
									<span>售后单号：{{item.afterSn}}</span>
									<span>订单号：{{item.orderInfoSn}}</span>
									<span>下单时间：{{item.orderCreateTime}}</span>
									<span v-if="item.status == 2">订单状态：待发货</span>
									<span v-else-if="item.status == 3">订单状态：待收货</span>
									<span v-else>订单状态：已收货</span>
									<span>收货人电话：{{item.mobile}}</span>
									<span>售后时间：{{item.afterCreateTime}}</span>
								</td>
							</tr>
							<tr class="order-table-item">
								<td class="order-table-image">
									<div class="order-table-image-wrap">
										<img :src="imgAddress + item.goodsImage" @error="error(1)"/>
									</div>
									<div>
										<div class="order-goods-name">{{item.goodsName}}</div>
										<div class="order-default-font order-guige">{{item.specName}}</div>
									</div>
								</td>
								<td class="order-default-font">
									<div>¥{{item.salePrice/100}}</div>
									<div class="order-item-time">（含运费：¥{{item.refundPostage/100}})</div>
								</td>
								<td class="order-default-font">{{item.refundAmount}}</td>
								<td>
									<div>{{item.applicationReason}}</div>
								</td>
								<td>
									<div>{{item.refundType}}</div>
								</td>
								<td>
									<div v-if="item.status == 1">商家已受理</div>
									<div v-else-if="item.status == 2">商家已同意</div>
									<div v-else-if="item.status == 3">商家退款成功</div>
									<div v-else>商家拒绝</div>
								</td>
								<td class="order-toDetail">
									<router-link tag="a" target="_blank" :to="{name: 'AfterSale', query: { id: item.afterSalesId}}" class="font-color-orange cursor-pointer">查看售后详情</router-link>
									<!-- <div class="order-default-font" v-if="item.refund == 1">查看售后</div> -->
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="afs-content-wrap padding-bot-20 mar-bot-20">
					<div>订单信息</div>
					<table class="shelves-table">
						<thead>
							<tr>
								<th>商品信息</th>
								<th>单价</th>
								<th>数量</th>
								<th>订单实际金额</th>
							</tr>
						</thead>
						<tbody class="order-tbody">
							<tr>
								<td colspan="7" class="self-tbody-space"></td>
							</tr>
							<tr>
								<td colspan="7" class="shelves-table-block-title no-select">
									<span>订单号：{{orderInfo.orderSn}}</span>
									<span>下单时间：{{orderInfo.createTime}}</span>
								</td>
							</tr>
							<tr class="order-table-item" v-for="(item, index) in goodsInfo">
								<td class="order-table-image">
									<div class="order-table-image-wrap">
										<img :src="imgAddress + item.navigateImg1" @error="error(1)"/>
									</div>
									<div>
										<div class="order-goods-name">{{item.goodName}}</div>
										<div class="order-default-font order-guige">{{item.specName}}</div>
									</div>
								</td>
								<td>
									<div>¥{{item. salePrice/100}}</div>
								</td>
								<td>
									<div>{{item.quantity}}</div>
								</td>
								<td v-if="index == 0" :rowspan="goodsInfo.length">
									<div>¥{{item.totalFee/100}}(含运费¥{{orderInfo.freight/100}})</div>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="afs-content-wrap padding-bot-20 mar-bot-20">
					<div>买家信息</div>
					<div class="afs-infor">
						<div>
							客户收货地址： {{addressInfo.province + addressInfo.city + addressInfo.area + addressInfo.address}}
						</div>
						<div>
							客户姓名： {{addressInfo.linkMan}}
						</div>
						<div>
							客户手机号： {{addressInfo.mobile}}
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
	import {imgAddress, afsDetail, applyAfs, saveAfs, upload, logistics, submitLogistics, logisticsInit} from '../config/interface.js'
	import {toast, imageError} from '../util/tool.js'
	import {fetch} from '../config/fetch.js'
	import store from '../store/index.js'
	import router from '../router/index.js'

	export default{
		data(){
			return {
				imgAddress: imgAddress,
				num1: 1,
				options: [],
		        value: '',
		        desc: '',
		        dialogImageUrl: '',
        		dialogVisible: false,
        		fileList: [],
        		statusShow: true,
        		company: '',
        		logisticsSn: '',
        		afterSaleId: '',
        		userId: store.state.userId,
        		detailId: '',
        		orderId: '',
        		applyData: {},
        		addressInfo: {},
        		goodsInfo: {},
        		orderInfo: {},
        		refundList: {},
        		refundInfo: {},
        		isRefund: 1,
        		imgProofs: [],
        		afterSalesDetail: {},
        		status1: 0,
        		status2: 0,
        		status3: 0,
        		current: 1,
        		address: {},
        		logisticsData: {},
        		logisticsName: '',
        		showRefundList: true,
        		showLogistics: false,
        		logisticsDetail: {}
			}
		},
		created(){
			this.afterSaleId = this.$route.query.id;
			this.orderId = this.$route.query.orderId;
			this.detailId = this.$route.query.detailId;
		},
		mounted(){
			if(this.afterSaleId == undefined){
				this.statusShow = true;
				this.applyInit();
			}else{
				this.statusShow = false;
				this.init();
				this.logisticsInit();
			}
		},
		methods: {
			init(){
				var data = {
					afterSalesId: this.afterSaleId,
					userId: this.userId
				};
				var url = afsDetail;

				fetch(url, data)
				.then(res=>{
					this.addressInfo = res.data.addressInfo;
					if(res.data.refundList.length == 0){
						this.showRefundList = false;
					}else{
						this.showRefundList = true;
						this.refundList = res.data.refundList;
					}
					for(var i=0; i < this.refundList.length; i++){
						this.refundList[i].afterCreateTime = this.refundList[i].afterCreateTime.substring(0,19);
					}
					this.afterSalesDetail = res.data.afterSalesDetail;
					this.address = this.afterSalesDetail.address;
					this.goodsInfo = res.data.goodsDetail;
					var orderInfo = {
						createTime: this.afterSalesDetail.orderCreateTime.substring(0,19),
						freight: this.goodsInfo[0].totalFee,
						orderSn: this.afterSalesDetail.orderInfoId,
						totalFee: this.goodsInfo.totalPrice
					};
					this.orderInfo = orderInfo;
					if(this.afterSalesDetail.status == '1'){
						this.status1 = 1;//商家审核中
						this.current = 2;
					}else if(this.afterSalesDetail.status == '2'){
						this.status1 = 2;//商家同意售后
						this.current = 2;
					}else if(this.afterSalesDetail.status == '3'){
						this.status1 = 2;//商家同意售后
						if(this.afterSalesDetail.isRefund == '1'){
							this.status2 = 2;//商家退款成功
							this.status3 = 1;//不显示
							this.current = 3;
						}else{
							this.status2 = 1;//商品回寄，商家处理中,商家退款成功
							this.status3 = 2;//售后完成
							this.current = 3;
						}
					}else if(this.afterSalesDetail.status == '4'){
						this.status1 = 3;//商家拒绝
						this.current = 2;
					}
					this.getLogistics();
				});
			},
			applyInit(){
				var data = {
					orderDetailId: this.detailId,
					orderInfoId: this.orderId,
					userId: this.userId
				};
				var url = applyAfs;

				fetch(url, data)
				.then(res=>{
					this.addressInfo = res.data.addressInfo;
					this.goodsInfo = res.data.goodsInfo;
					this.orderInfo = res.data.orderInfo;
					this.orderInfo.createTime = this.orderInfo.createTime.substring(0,19);
					this.refundInfo = res.data.refundInfo;
					if(res.data.refundList.length == 0){
						this.showRefundList = false;
					}else{
						this.showRefundList = true;
						this.refundList = res.data.refundList;
					}
					for(var i=0; i < this.refundList.length; i++){
						this.refundList[i].afterCreateTime = this.refundList[i].afterCreateTime.substring(0,19);
					}
					this.options = res.data.refundReason;
				});
			},
			logisticsInit(){
				var data = {
					userId: this.userId
				};
				var url = logistics;

				fetch(url, data)
				.then(res=>{
					this.logisticsData = res.data;
				})
			},
			error(num){
				imageError(num, event);
			},
			handleRemove(file, fileList){
		        console.log(file, fileList);
		    },
		    handleChange(file, fileList){	    	
		    	this.fileList = fileList.slice(-3);
		    	var Img = new Image(),
		    		dataURL = '',
		    		type = file.raw.type,
		    		self = this;
		    	Img.src = file.url;
		    	var suffix = type.substring(6);
		    	var file1 = file;
		    	Img.onload=function(){
		    		var canvas = document.createElement("canvas"),
		    			width = Img.width,
		    			height = Img.height;
		    		canvas.width = width;
		    		canvas.height = height;
		    		canvas.getContext("2d").drawImage(Img,0,0,width,height);
		    		dataURL=canvas.toDataURL(type, 0.3);
		    		var handleUrl = dataURL.split(",")[1];
		    		var data = {
		    			imgBase: handleUrl,
		    			suffix: suffix,
		    			userId: self.userId
		    		};
		    		var url = upload;

		    		fetch(url, data)
		    		.then(res=>{
		    			var imgProof = res.data;
		    			for(var i = 0; i < self.fileList.length; i++){
		    				if(self.fileList[i].uid == file1.uid){
		    					self.fileList[i].imgProof = imgProof;
		    				}
		    			}
		    		});
		    	}
		    },
		    handlePictureCardPreview(file){
		        this.dialogImageUrl = file.url;
		        this.dialogVisible = true;
		    },
		    handleIsRefund(){
		    	if(this.isRefund==1){
		    		this.isRefund=2;
		    	}else{
		    		this.isRefund=1;
		    	}
		    },
		    saveAfs(){
		    	var data = {
		    		applicationReason: this.value,
		    		isRefund: this.isRefund,
		    		refundNum: this.num1,
		    		orderDetailId: this.detailId,
		    		orderInfoId: this.orderId,
		    		userId: this.userId,
		    		userReason: this.desc,
		    		imgProof1: '',
		    		imgProof2: '',
		    		imgProof3: ''
		    	};
		    	if(this.fileList.length == 1){
		    		data.imgProof1 = this.fileList[0].imgProof;
		    	}else if(this.fileList.length == 2){
		    		data.imgProof1 = this.fileList[0].imgProof;
		    		data.imgProof2 = this.fileList[1].imgProof;
		    	}else if(this.fileList.length == 3){
		    		data.imgProof1 = this.fileList[0].imgProof;
		    		data.imgProof2 = this.fileList[1].imgProof;
		    		data.imgProof3 = this.fileList[2].imgProof;
		    	}

		    	var url = saveAfs;
		    	fetch(url, data)
		    	.then(res=>{
		    		if(res.code == 10000){
			    		var str = "保存成功";
						toast(str, 1, false);
						router.push({ name: 'Order', params: { type: 'afs' }});
					}else{
						var str = "保存失败";
						toast(str, 2, false);
					}
		    	})
		    },
		    saveLogistics(){
		    	var data = {
		    		afterSalesId: this.afterSaleId,
		    		courierCompanyEn: this.company,
		    		courierNumber: this.logisticsSn,
		    		courierCompany: this.logisticsName,
		    		userId: this.userId
		    	};
		    	var url = submitLogistics;

		    	fetch(url, data)
		    	.then(res=>{
		    		if(res.code == 10000){
		    			var str = "提交成功";
						toast(str, 1, false);
						this.init();
		    		}else{
		    			var str = "提交失败";
						toast(str, 1, false);
		    		}
		    	})
		    },
		    getLogistics(){
		    	var data = {
		    		afterSn: this.afterSalesDetail.afterSn,
		    		userId: this.userId
		    	};
		    	var url = logisticsInit;

		    	fetch(url, data)
		    	.then(res=>{
		    		if(res.code == 10000){
		    			this.logisticsDetail = JSON.parse(res.data.logisticsSessage);
		    			var list = this.logisticsDetail.list;
						var arr = [];
						for(var i = 0; i < list.length; i++){
							arr.push(list[list.length - (i + 1)]);
						}
						this.logisticsDetail.list = arr;
						this.showLogistics = true;
		    		}else{
		    			this.showLogistics = false;
		    		}
		    	})
		    },
		    handleSelect(val){
		    	var id = val;
		    	for(var i = 0; i < this.logisticsData.length; i++){
		    		if(id == this.logisticsData[i].companyNo){
		    			this.logisticsName = this.logisticsData[i].companyName;
		    		}
		    	}
		    }
		}
	}
</script>